<template>
  <el-container class="setting_shopping-mall_goods-set">
    <el-main>
      <div class="wrapper-box">
        <div class="dis">
          <div class="fin-setting-content">
            <el-form  ref="h5Set" :model="params" >
            <el-card shadow="never" class="cardInfo">
              <div class="bg-white-panel">H5功能参数设置</div>
              <div class="dis al_item">
                <div class="nav-item">
                  <div class="dis al_item dis_ju_spb item-header">
                    <div class="cursor flex_1 dis al_item">
                        <el-form-item class="person-center-form-item">
                          <span class="form-item-title">开启H5功能：</span>
                          <el-switch v-model="params.openH5" label="关闭"  :active-value="1" :inactive-value="2" @change="handleChange" />
                          <span class="form-item-title">关闭  (开启后，可以在各功能页面发布H5页面，可以通过H5对外分享)</span>
                        </el-form-item>
                    </div>
                  </div>
                  <div v-if="params.openH5 == 1" class="dis al_item">
                    <div class="cursor flex_1 dis al_item">
                        <el-form-item class="person-center-form-item" style="margin-left: 50px;">
                          <span class="form-item-title">H5发布域名：</span>
                            <el-input placeholder="请输入内容" v-model="params.domain" class="input-with-select" size="small" style="width: 300px;">
                              <el-select v-model="params.protocol" slot="prepend" placeholder="请选择">
                                <el-option label="http://" value="http://"></el-option>
                                <el-option label="https://" value="https://"></el-option>
                              </el-select>
                            </el-input>
                          <span class="form-item-title">全链接  ({{params.fullShorterUrl}})</span>
                        </el-form-item>
                    </div>
                  </div>
                </div>
              </div>
            </el-card>
            </el-form>
          </div>
        </div>
      </div>
      <div class="btn-footer">
        <el-button>取消</el-button>
        <el-button type="primary" @click="submit">保存</el-button>
      </div>

    </el-main>
  </el-container>
</template>

<script>
import { viewH5Setting, saveH5Setting } from '@/api/channelSetting'
export default {
  components: {
  },
  data() {
    return {
      params: {
        openH5: 2,
        protocol: 'http://',
        domain: '',
        tenantId: '',
        fullShorterUrl: '',
        path: '',
        fullUrl: ''
      }
    }
  },
  mounted() {
    this.getH5SettingInfo()
  },
  methods: {
    handleChange(val) {
      this.params.openH5 = val
    },
    getH5SettingInfo() {
      viewH5Setting().then(res => {
        if (res) {
          this.params = res
          console.log(res)
        }
      })
    },
    // 保存
    submit() {
      if(this.params.openH5 === 2){
          this.params.protocol = ''
          this.params.domain = ''
      }
      this.$confirm('确认要修改配置?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        saveH5Setting(this.params).then(res => {
          if (res) {
            this.$message.success('保存成功！')
            this.getH5SettingInfo()
          }
        })
      })
    }
  }
}
</script>

<style lang="scss">
  .setting_shopping-mall_goods-set {
    .check-box-w{
      width: 60%;
    }
    background: #d8d8d8;
    padding: 4px;
    height: 90%;
    border-radius: 3px;
    overflow: auto;
    .clearfix{
      padding:5px;
      padding-top: 0;
      height: 15px;
      display: flex;
      align-items: center;
      >div {
        border: 0px solid #e6ebf5;
        flex-grow: 1;
        width:0;
        margin-right: 20px;
      }
    }
    }
    .fin-setting-content {
      width: 100%;
      margin: 0px 0 4px 4px;
      overflow-x: hidden;
      overflow-y: auto;
      border-radius:5px;
      .cardInfo {
          margin-top: 2px;
          padding: 2px;
       }
      .user-center-item {
        box-sizing: border-box;
        cursor: pointer;
        padding-bottom: 10px;
        &.active {
          border: 1px solid #1890ff
        }
      }

    }
    .nav-item {
      font-size: 14px;
      background: #ffffff;
      border: 0px solid #e3e2e5;
      border-radius: 4px;
      margin-bottom: 10px;
      width: 100%;
      display: inline-block;

      &:nth-child(odd) {
        margin-right: 10px;
        font-size: 14px;
        color: #595961;
      }

      .item-header {
        border-radius: 4px 4px 0 0;
        // height: 32px;
        line-height: 39px;
        padding: 0 10px 0 5px;
      }

      .item-content {
        padding: 5px 0;
      }
    }
    .person-center-form-item {
      font-size: 14px;
      margin-left: 20px;
      display:inline-flex;
      justify-content: flex-end;
      .el-form-item__label, .el-form-item__content, .el-radio__label, .el-button, .el-checkbox .el-checkbox__label {
        font-size: 13px;
        color: #172161;
      }
      .el-input-number.is-without-controls.el-input__inner{
        width: 20px;
        height: 14px;
      }
      .el-input.is-without-controls.el-input__inner{
        height: 14px;
      }
      .form-item-input{
        min-height: 14px;
        width: 300px;
        font-size: 12px;
        .el-input__inner{
           padding-right: 45px;
        }
      }
      .form-item-title{
        padding-left: 6px;
        padding-right: 6px;
        color: #666;
      }
      .flex-just{
        vertical-align: middle;
        width: 90px;
      }
    }
    .base-info {
      display: flex;
      .basics-info {
        margin: 0 auto;
      }
    }
    .el-form-item  {
      margin-bottom: 30px;
    }
    .el-col {
      margin-bottom: 0px;
    }
    .noMargin {
      margin-bottom: 0 !important;
    }
  .bg-white-panel {
    padding: 5px;
    font-size: 14px;
    font-weight: bolder;
    border-radius: 4px;
    margin-bottom: 5px;
  }
  .el-select .el-input {
    width: 100px;
  }
  .input-with-select .el-input-group__prepend {
    background-color: #fff;
  }
</style>
